package com.example.basicknowledge.运动事件的处理;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.MotionEvent;
import android.widget.TextView;

import com.example.basicknowledge.R;

public class CatchMotionEvent extends AppCompatActivity {

    TextView mAction;
    TextView mPostion;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.catch_motion_event);
        mAction = (TextView)findViewById(R.id.textView4);
        mPostion = (TextView)findViewById(R.id.textView5);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        int Action = event.getAction();
        float x = event.getX();
        float y = event.getY();
        System.out.println("Action =" + Action);
        System.out.println("x = " + x + "   y = " + y);

        mAction.setText(String.valueOf(Action));
        mPostion.setText("(" + x + "," + y + ")");

        return super.onTouchEvent(event);
    }
}
